import 'package:flutter/material.dart';
import 'package:pd_application/routes.dart';

class LoginPage extends StatefulWidget {
  const LoginPage({super.key});

  @override
  State<LoginPage> createState() => _LoginPageState();
}

class _LoginPageState extends State<LoginPage> {
  bool _isObscure = false;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('登录'),
        backgroundColor: Theme.of(context).primaryColor,
      ),
      body: SafeArea(
        minimum: const EdgeInsets.all(30),
        child: ListView(children: [
          // 用户名
          const TextField(
              decoration: InputDecoration(
            prefixIcon: Icon(Icons.person),
            labelText: '用户名',
            hintText: '请输入用户名',
          )),
          const Padding(padding: EdgeInsets.all(20.0)),
          // 密码
          TextField(
              obscureText: !_isObscure,
              decoration: InputDecoration(
                prefixIcon: const Icon(Icons.lock),
                labelText: '密码',
                hintText: '请输入密码',
                suffixIcon: IconButton(
                  icon: Icon(
                      _isObscure ? Icons.visibility : Icons.visibility_off),
                  onPressed: () {
                    setState(() {
                      _isObscure = !_isObscure;
                    });
                  },
                ),
              )),
          const Padding(padding: EdgeInsets.all(20.0)),
          // 添加其他表单元素
          // 登录按钮
          ElevatedButton(
              style: ElevatedButton.styleFrom(
                minimumSize: const Size.fromHeight(50), // 设置按钮高度
                backgroundColor: Theme.of(context).primaryColor,
              ),
              onPressed: () {
                // 处理登录按钮点击事件
              },
              child: const Text(
                '登录',
                style: TextStyle(
                  fontSize: 20,
                  color: Colors.white,
                ),
              )),
          const Padding(padding: EdgeInsets.all(20.0)),
          // 注册按钮
          Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              const Text('没有账号？'),
              TextButton(
                  onPressed: () {
                    // 处理注册按钮点击事件
                    Navigator.pushReplacementNamed(context, Routes.REGISTER);
                  },
                  child: const Text(
                    '注册',
                    style: TextStyle(
                      color: Colors.blue,
                    ),
                  ))
            ],
          )
        ]),
      ),
    );
  }
}
